#pragma once

#include <mshtml.h>

class TGetHtmlText
{
public:
	TGetHtmlText(void);
	~TGetHtmlText(void);

	static BOOL IsIEPage(HWND hWnd);
	BOOL IsValid() const;
	BOOL Attach(HWND hWnd);

	enum IEVERSION
	{
		MSIEUNK=-1, MSIE5 = 0, MSIE6, MSIE7, MSIE8, MSIE9
	};
	UINT GetIEVersion() const;

	CComPtr<IHTMLElement> GetElementFromPoint(IHTMLDocument2* pDoc2, POINT pt, CComPtr<IHTMLDocument2>& spSubDoc2, POINT& ptRelative);
	CComPtr<IHTMLDocument2> GetParentDocFromElement(IHTMLElement* pElement);
	CComBSTR GetTextFromPoint(POINT pt);
	void GetScrollXY( IHTMLDocument2* pDoc, long* x, long* y);
	CComBSTR GetTextFromPoint(IHTMLDocument2* pParentDoc2, POINT ptRelative);
	CComBSTR GetTextFromPoint(IHTMLInputElement* pInput, POINT ptRelative);
	CComBSTR GetTextFromTxtRange(IHTMLTxtRange* pTxtRange, POINT ptRelative);

	CComPtr<IHTMLDocument2> DocumentFromHtmlWindow(IHTMLWindow2* spWindow2);

	CComBSTR GetTextFromSelectElement(IHTMLSelectElement* pSelectElement);
private:
	HWND m_hWnd;
	UINT m_nVersion;
	CComPtr<IHTMLDocument2> m_spDoc2;
};
